package com.manner.groupon.controller.store;

import com.manner.groupon.common.BaseResponse;
import com.manner.groupon.common.PageResult;
import com.manner.groupon.model.dto.order.AdminWithDTO;
import com.manner.groupon.model.dto.store.WithDrawDTO;
import com.manner.groupon.model.entity.WithDrawRecord;
import com.manner.groupon.model.vo.AdminWithVO;
import com.manner.groupon.service.store.WithDrawRecordService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/with-draw")
    
public class WithDrawController {

    @Resource
    private WithDrawRecordService withDrawRecordService;


    @PostMapping
    public BaseResponse<String> save(@RequestBody WithDrawDTO withDrawDTO) {
        return withDrawRecordService.insert(withDrawDTO);
    }

    @GetMapping("/{phone}")
    public BaseResponse<List<WithDrawRecord>> list(@PathVariable String phone) {
        return withDrawRecordService.list_search(phone);
    }

    @GetMapping("/admin")
    public BaseResponse<PageResult<AdminWithVO>> search(AdminWithDTO adminWithDTO) {
        return withDrawRecordService.query_search(adminWithDTO);
    }

    @PutMapping("/draw/{id}")
    public BaseResponse<String> update(@PathVariable Long id) {
        return withDrawRecordService.updateWith(id);
    }

}
